#include "stdio.h"
#include "stdlib.h"
char c[10][10]={
	"",
	"",
	"ABC",
	"DEF",
	"GHI",
	"JKL",
	"MNO",
	"PQRS",
	"TUV",
	"WXYZ",
};
const int telLength = 3;
const int total[10] = {0,0,3,3,3,3,4,3,3,4};

int parsenumber(char charnumber[],int *number,int *answer,int telLength)
{
	if (strlen(charnumber) != telLength)
		return -1;
	for (int i = 0; i < telLength; ++i)
	{
		number[i] = charnumber[i]-48;
		
		if ( ( number[i] >9 ) || (number[i] < 0) )
			return -1 ;

		answer[i] = 0;
		//printf("%d\n", number[i]);
		//printf("%d\n",answer[i] );
	}
	return 0;
}

int printnumber(int *number, int *answer,int telLength)
{
	int k = telLength -1;
	
	while(1)
	{
		for (int i = 0; i < telLength; ++i)
		{
			printf("%c",c[number[i]][answer[i]]);
		}
		printf("\n");

        k = telLength -1;
       // the method for write in loop 
        while(k >= 0)
        {
        	if ( answer[k] < total[number[k]] -1 )
        	{
        		answer[k] ++ ;
        		break;
        	}	
        	else {
        		answer[k] = 0;
        		k --;
        	}
        }
    	if (k < 0)
    		break;   
	}
	return 0 ;
}
int main(int argc, char const *argv[])
{
	int number[telLength] ;
	int answer[telLength] ;

	if (parsenumber(argv[1],number,answer,telLength) != -1)
    {
    	printnumber(number,answer,telLength);
    	return 0;
    }
    else 
	{
		printf ("parse failed");
		return 0;
	}
}
